import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86131
 * Date: 2024-05-04
 * Time: 16:18
 */
/*Tomcat 不是收到所有的get请求都调用这个doGet方法,而是同时判断
* 1. 请求是 get
* 2. 请求 url路径是/hello
* */
@WebServlet("/hello")
public class HelloServlet extends HttpServlet {
    //继承是重写父类的方法

    //doGet的意思是处理HTTP GET请求
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //这个打印显示在tomcat的控制台上(服务器端)
        System.out.println("hello world");
        //把内容显示到页面上
        resp.getWriter().write("hello world!!");
    }
}
